﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebProjectOrder.WebServices;

namespace WebProjectOrder.BusinessLayer
{
    public class ItemManager
    {
        #region Atributos
        private bool _IsError;
        private String _ErrorMessage;
        private bool _DefiniteError;
        private static ItemManager _instance;
        private List<StoreItem> _StoreItems;
        #endregion

        #region Propiedades
        public bool IsError
        {
            get
            {
                bool temp = _IsError;
                _IsError = false;
                return temp;
            }
        }

        public String ErrorMessage
        {
            get
            {
                String temp = _ErrorMessage;
                _IsError = false;
                _ErrorMessage = "";
                return temp;
            }
        }
        #endregion

        #region Constructor
        /// <summary>
        /// Constructor privado de la clase para permitir la implementación del patrón singlenton
        /// </summary>
        private ItemManager() 
        {
            
        }
        /// <summary>
        /// Método que obtiene la instancia existente de la clase. 
        /// </summary>
        /// <returns></returns>
        public static ItemManager GetInstance() 
        {
            if (_instance == null)
                _instance = new ItemManager();
            return _instance;
        }
        #endregion

        #region Métodos
        public List<StoreItem> GetStoreItem(int idStore) 
        {
            _StoreItems = WebServices.WebServices.getInstance().GetStoreItem(idStore);
            if (_StoreItems == null) 
            {
                _IsError = true;
                _ErrorMessage = Constants.ERROR_STORE_ROOM_ARTICLE_READING; 
            }
            return _StoreItems;

        }
        #endregion


    }
}